# coding:utf-8
# 作者：理想国真恵玩
import pandas as pd

df1 = pd.DataFrame({'a': [1, 2, 3], 'b': [2, 3, 4], 'c': [3, 4, 5]})
df2 = pd.DataFrame({'b': [1, 2, 3], 'c': [2, 3, 4], 'd': [3, 4, 5]})
print(df1)
print('-' * 33)
print(df2)
print('-' * 33)

# 按照相同的键合并
# 内连接： 会去除掉多余的部分，取的是交集
df3 = pd.merge(df1, df2, how='inner', on=['b', 'c'])
print(df3)
print('-' * 33)

# 左外连接
df4 = pd.merge(df1, df2, how='left', on=['b', 'c'])
print(df4)
print('-' * 33)

# 右外连接
df5 = pd.merge(df1, df2, how='right', on=['b', 'c'])
print(df5)
print('-' * 33)

# 外连接
df6 = pd.merge(df1, df2, how='outer', on=['b', 'c'])
print(df6)
print('-' * 33)
